package tools;

import lombok.Getter;
import lombok.Setter;

/**
 * idCardTypes: {1: '身份证', 2: '护照', 3: '港澳通行证', 4: '台胞证', 5: '居住证', 6: '临时居住证', 99: '其他证件'}
 */
public enum IdCardTypeEnums {

    UNKOWN(0, "unkown", "未知"),
    ID_CARD(1, "idCard", "身份证"),
    PASSPORT(2, "passport", "护照"),
    HMPASS(3, "hmpass", "港澳通行证"),
    MTP(4, "mtp", "台胞证"),
    RP(5, "rp", "居住证"),
    TEMP_RP(6, "temp_rp", "临时居住证"),
    LICENSE(7, "license", "营业执照"),
    other(99, "other", "其他证件"),
    ;

    @Getter
    @Setter
    private int value;
    @Getter
    @Setter
    private String desc;
    @Getter
    @Setter
    private String keyStr;


    IdCardTypeEnums(int value, String keyStr, String desc) {
        this.value = value;
        this.keyStr = keyStr;
        this.desc = desc;
    }

    public static IdCardTypeEnums getByValue(int value) {
        for (IdCardTypeEnums ve : values()) {
            if (ve.value == value) {
                return ve;
            }
        }
        return UNKOWN;
    }

    public static IdCardTypeEnums getByKey(String key) {
        for (IdCardTypeEnums ve : values()) {
            if (ve.keyStr.equals(key)) {
                return ve;
            }
        }
        return UNKOWN;
    }

}
